import { lazyReportBatch } from "../report";

export default function click() {
  ["mousedown", "touchstart"].forEach((eventType) => {
    window.addEventListener(
      eventType,
      (e) => {
        const target = e.target;
        if (target.tagName) {
          const reportData = {
            type: "behavior",
            subType: "click",
            target: target.tagName,
            startTime: performance.now(),
            innerHtml: target.innerHTML,
            outerHtml: target.outerHTML,
            width: target.offsetWidth,
            height: target.offsetHeight,
            eventType,
            path: e.path,
          };
          lazyReportBatch(reportData);
        }
      },
      true
    );
  });
}
